<template>
  <base-option :selected="selected" :field-config="fieldConfig" :form-config="formConfig">
    <template #default="{ hideOptions }">
      <el-form-item v-if="fieldConfig.defaultValue !== undefined && hideOptions('defaultValue')" label="默认值">
        <el-input-number v-model="fieldConfig.defaultValue" :min="fieldConfig.min" :max="fieldConfig.max" />
      </el-form-item>

      <el-form-item v-if="fieldConfig.append !== undefined && hideOptions('append')" label="后置内容">
        <el-input v-model="fieldConfig.append" maxlength="3" placeholder="请输入后置显示文字" />
      </el-form-item>

      <el-form-item v-if="fieldConfig.min !== undefined && hideOptions('min')" label="最小值">
        <el-input-number v-model="fieldConfig.min" :min="0" :max="fieldConfig.max" controls-position="right" />
      </el-form-item>
      <el-form-item v-if="fieldConfig.max !== undefined && hideOptions('max')" label="最大值">
        <el-input-number v-model="fieldConfig.max" :min="fieldConfig.min" controls-position="right" />
      </el-form-item>
    </template>
  </base-option>
</template>

<script setup>
import { toRefs } from 'vue'
import baseOption from './base-option.vue'
import propsDefinition from './props'
const props = defineProps(propsDefinition)
const { selected, widgetList, fieldConfig, formConfig } = toRefs(props)
</script>
